package edge

import (
	"iot-base/common/notify"
	"iot-base/common/types"
)

type taskHandle func(params []byte) ([]byte, error)

var taskEdgeAction = map[string]taskHandle{
	"AddEdgeTask":    AddEdgeTask,
	"DelEdgeTask":    DelEdgeTask,
	"ModifyEdgeTask": ModifyEdgeTask,
}

func SubEdgeMsg() {
	notify.EdgeSubActionCmd(func(params *types.ReqActionData) ([]byte, error) {
		if fun, ok := taskEdgeAction[params.Action]; ok {
			return fun(params.Params)
		}
		return nil, notify.ErrActionNotFound
	})
}
